package webserver;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;

/**
 * 主程序执行，端口的设置，开启新线程调用processor处理
 * @author fufan14863
 *
 */
public class WebServer {

	public void serverStart(int port){
		try {
			ServerSocket serverSocket = new ServerSocket(port);
			
			while(true){
				Socket socket = serverSocket.accept();
				new Processor(socket).start();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		int port = 80;
		if(args.length == 1){
			port = Integer.parseInt(args[0]);
		}
		new WebServer().serverStart(port);
	}
}